001    /**
002     * Created by IntelliJ IDEA.
003     * User: Wei Wang
004     * Date: Apr 28, 2003
005     * Time: 1:18:02 PM
006     */
007    
008    package EVolve.util.phasedetectors.phasedetectorUI;
009    
010    import javax.swing.*;
011    import java.awt.*;
012    
013    public class CheckBoxItemRenderer extends JCheckBox implements ListCellRenderer{
014    
015        public CheckBoxItemRenderer() {
016             setOpaque(true);
017        }
018    
019        public Component getListCellRendererComponent(
020            JList list,
021            Object value,
022            int index,
023            boolean isSelected,
024            boolean cellHasFocus)
025        {
026            setBackground(isSelected ? Color.blue : Color.lightGray);
027            setForeground(isSelected ? Color.yellow : Color.black);
028            setSelected(((JCheckBox)value).isSelected());
029            setText(((JCheckBox)value).getText());
030            return this;
031        }
032    }